{% extends "manage/layout.html" %}

{% set page_title = '添加渠道' %}

{% block content %}
<div class="m-content">
    <form class="form-horizontal" method="POST" id="{{ form.__class__.__name__ }}">
		{{ form.hidden_tag() }}
		<fieldset class="fieldset">
			<legend>渠道信息</legend>
			{% from "common/_formhelper.html" import render_field %}
			{{ render_field(form.name, class_="form-control", required=True) }}
			{{ render_field(form.address, class_="form-control", required=True) }}
			{% from "common/_formhelper.html" import render_select %}
			{{ render_select(form.wx_group_id) }}
			{#
			{{ render_field(form.start_at, placeholder="yyyy-mm-dd", class_="form-control", required=True) }}
			{{ render_field(form.end_at, placeholder="yyyy-mm-dd", class_="form-control", required=True) }}
			#}
		</fieldset>

		<fieldset>
			<div class="col-sm-offset-2 col-sm-4">
				<button class="btn btn-default submit-exh">确认</button>
				<a href="{{ url_for('manage.exhibitions') }}" class="btn btn-default">返回</a>
			</div>
		</fieldset>
	</form>
</div>
{% endblock %}

{% block js %}
<script>
$(function(){
	$('select[name="wx_group_id"]').change(function(){
		var wx_group_name = $('select[name="wx_group_id"] option:selected').text();
		$('#wx_group_name').val(wx_group_name)
	});
	$('.submit-exh').click(function(){
		var wx_group_name = $('select[name="wx_group_id"] option:selected').text();
		$('#wx_group_name').val(wx_group_name)
	});
	$('#start_at').datetimepicker({
		format:'yyyy-mm-dd',
		autoclose:true,
		todayBtn:true,
		minView:2,
		language: 'zh-CN'
	});     
	$('#end_at').datetimepicker({
		format:'yyyy-mm-dd',
		autoclose:true,
		todayBtn:true,
		minView:2,
		language: 'zh-CN'
	});     
});
</script>
{% endblock %}
